clear
cd "/Users/john/Dropbox/Turnout/TurnoutProjectNotes/WhoVotes/CrossNational/AfroBarometer"
use "/Users/john/Dropbox/Turnout/TurnoutProjectNotes/WhoVotes/CrossNational/AfroBarometer/ab.dta"
decode RESPNO, gen(respno)
sort respno
merge respno using dates



***Coding Rules
*Party counted if more than 1% adherents

***Voting
gen voted=1 if Q21==3
replace voted=0 if voted~=1
replace voted=. if Q21==11 | Q21==13 | Q21==10 | Q21==1


****Regime vs Opposition
numlabel Q90B, add

gen regime_party_supporter=1 if Q90B==293  | Q90B==294
gen opp_party_supporter=1 if Q90B==295 | Q90B==296 | Q90B==298 | Q90B==299 | Q90B==300 | Q90B==301 | Q90B==302 
tab voted if regime_party_supporter==1 & COUNTRY==1
tab voted if opp_party_supporter==1 & COUNTRY==1
**Dropping Boycotting parties
drop regime_party_supporter
drop opp_party_supporter
gen regime_party_supporter=1 if Q90B==293  | Q90B==294
gen  opp_party_supporter=1 if Q90B==295 | Q90B==296 | Q90B==299 | Q90B==300 | Q90B==301 | Q90B==302 

**These are quantities in table
tab voted if regime_party_supporter==1 & COUNTRY==1
tab voted if opp_party_supporter==1 & COUNTRY==1




***Cameroon
tab voted if COUNTRY==6

replace regime_party_supporter=1 if Q90B==274 
replace opp_party_supporter=1 if Q90B==276 | Q90B==277 | Q90B==275 
tab voted if regime_party_supporter==1 & COUNTRY==6
tab voted if opp_party_supporter==1 & COUNTRY==6


***Guinea
tab voted if COUNTRY==12


replace regime_party_supporter=1 if Q90B==287
replace opp_party_supporter=1 if Q90B==288 | Q90B==289 | Q90B==290
tab voted if regime_party_supporter==1 & COUNTRY==12
tab voted if opp_party_supporter==1 & COUNTRY==12


***Mozambique
tab voted if COUNTRY==21


replace regime_party_supporter=1 if Q90B==135
replace opp_party_supporter=1 if Q90B==137 | Q90B==136
tab voted if regime_party_supporter==1 & COUNTRY==21
tab voted if opp_party_supporter==1 & COUNTRY==21




***Nigeria
tab voted if COUNTRY==24

replace regime_party_supporter=1 if Q90B==164
replace opp_party_supporter=1 if Q90B==155 | Q90B==151 | Q90B==157
tab voted if regime_party_supporter==1 & COUNTRY==24
tab voted if opp_party_supporter==1 & COUNTRY==24




***Tanzania
tab voted if COUNTRY==31


replace regime_party_supporter=1 if Q90B==197
replace opp_party_supporter=1 if Q90B==198 | Q90B==199
tab voted if regime_party_supporter==1 & COUNTRY==31
tab voted if opp_party_supporter==1 & COUNTRY==31



***Togo
tab voted if COUNTRY==32


replace regime_party_supporter=1 if Q90B==255
replace opp_party_supporter=1 if Q90B==256 | Q90B==264 | Q90B==257
tab voted if regime_party_supporter==1 & COUNTRY==32
tab voted if opp_party_supporter==1 & COUNTRY==32

***Uganda
tab voted if COUNTRY==34


replace regime_party_supporter=1 if Q90B==204
replace opp_party_supporter=1 if Q90B==205 | Q90B==206 | Q90B==208
tab voted if regime_party_supporter==1 & COUNTRY==34
tab voted if opp_party_supporter==1 & COUNTRY==34


***Zimbabwe
tab voted if COUNTRY==36


replace regime_party_supporter=1 if Q90B==222
replace opp_party_supporter=1 if Q90B==221
tab voted if regime_party_supporter==1 & COUNTRY==36
tab voted if opp_party_supporter==1 & COUNTRY==36


**Malaysia
use "/Users/john/Dropbox/Turnout/TurnoutProjectNotes/WhoVotes/CrossNational/AsiaBarometer/W4 13. Malaysia/W4_Malaysia_20181211_release.dta", clear

gen voted=1 if q33==1
replace voted=0 if q33==2
tab voted
numlabel Q53, add
gen regime_supporter=1 if q53>1300 & q53<1310
gen opp_supporter=1 if q53>1309 & q53<1318
tab voted if regime_supporter==1
tab voted if opp_supporter==1


**Cambodia
use "/Users/john/Dropbox/Turnout/TurnoutProjectNotes/WhoVotes/CrossNational/AsiaBarometer/W4 12. Cambodia/W4_Cambodia_20181210_release.dta", clear

gen voted=1 if q33==1
replace voted=0 if q33==2
tab voted
numlabel Q53, add
gen regime_supporter=1 if q53==1204 | q53==1202
gen opp_supporter=1 if q53==1207| q53==1208
tab voted if regime_supporter==1
tab voted if opp_supporter==1


*Nicaragura 2012
use "/Users/john/Dropbox/Turnout/TurnoutProjectNotes/WhoVotes/CrossNational/LAPOP/Nicaragua2012.dta", clear
tab vb2
numlabel vb11, add
gen regime_supporter=1 if vb11==502
gen opp_supporter=1 if vb11==501 | vb11==504
tab vb2 if regime_supporter==1
tab vb2 if opp_supporter==1


*Kazakhstan
cd "/Users/john/Dropbox/Turnout/TurnoutProjectNotes/WhoVotes/CrossNational/Kazakhstan"
insheet using kazakh.csv, clear
rename В28 voted
rename В30 party
rename В9 approve_pol_direction


replace voted=. if voted==77 | voted==99
tab voted 

gen regime_supporter=1 if party==1
gen opp_supporter=1 if party>1 & party<77

tab voted if regime_supporter==1
tab voted if opp_supporter==1






